{% extends "piggy/base_generic.html" %}

{% block title %}
    <title> Register - Piggy </title>
{% endblock %}

{% block content %}
<form action="{% url 'piggy:register' %}" method="post">
{% csrf_token %}
<fieldset>
    <legend>Register</legend>
     {% if message %}
        {% for msg in message %}
            <p><strong>{{ msg }}</strong></p>
        {% endfor %}
    {% endif %}
    <table>
        <tr>
            <td>Name</td>
            <td><input type="text" name="name" value="{{ draft.name }}"/></td>
        </tr>
        <tr>
            <td>Username</td>
            <td><input type="text" name="username" value="{{ draft.username }}"/></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="password1" value="{{ draft.password1 }}"/></td>
        </tr>
        <tr>
            <td>Confirm password</td>
            <td><input type="password" name="password2" value="{{ draft.password2 }}"/></td>
        </tr>
    </table> 
    <div>
        {% if draft.role == 'student' %}
            <input type="radio" name="role" id="studentChoice" value="student" checked/>
            <label for="studentChoice">Student</label>
            <input type="radio" name="role" id="professorChoice" value="professor" />
            <label for="professorChoice">Professor</label>
        {% else %}
            <input type="radio" name="role" id="studentChoice" value="student"/>
            <label for="studentChoice">Student</label>
            <input type="radio" name="role" id="professorChoice" value="professor" checked/>
            <label for="professorChoice">Professor</label>
        {% endif %}
    </div>
    
    <div>
        <button type="submit">Submit</button>
    </div>
</fieldset>
</form>

{% endblock content %}

